﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Site.Master" AutoEventWireup="true" CodeBehind="AlbumEdit.aspx.cs" Inherits="VK.Casemeet.Web.Admin.Albums.AlbumEdit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="contentHead" runat="server">
    <script type="text/javascript" src="/Scripts/ajaxupload.js"></script>
    <script type="text/javascript">
        function butsubmit() {
            if (validator.form()) {
                //图片
                var imgUrlArray = new Array();
                $("#imgArea img").each(function (i) {
                    imgUrlArray[i] = $(this).attr("src").replace('/UserImages/Photos/', '');
                });
                $("#hidImgUrlArray").val(JSON.stringify(imgUrlArray));
                return true;
            } else {
                return false;
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentBody" runat="server">
    <div class="bodyContent divBody">
        <div class="divDetailOper">
            <asp:LinkButton ID="butSave" runat="server" CssClass="butSave" onclick="butSave_Click" OnClientClick="return butsubmit()">保存信息</asp:LinkButton>
            <a class="butBack" href="AlbumList.aspx">返回列表</a>
        </div>
        <div class="left" style="width:74%;margin:10px 0 0 1%;_margin:10px 0 0 0.5%;height:auto;">
            <div class="divEdit" style="width:100%;">
                <div class="title">基本信息</div>
                <div class="content">
                    <table cellpadding="0" cellspacing="0" class="tableLeftEdit">
                    <tbody>
                        <tr>
                            <th>类型：</th>
                            <td><asp:DropDownList ID="ddlObjectType" runat="server" CssClass="selectddl {min:1, messages:{min:'请选择一项'}}"></asp:DropDownList></td>
                        </tr>
                        <tr>
                            <th>主体编号：</th>
                            <td><asp:TextBox ID="txtObjectID" runat="server" CssClass="inputText required number" Width="80%"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <th>名称：</th>
                            <td><asp:TextBox ID="txtName" runat="server" CssClass="inputText required" Width="80%"></asp:TextBox></td>
                        </tr>
                    </tbody>
                    </table>
                </div>
            </div>
            <div class="divEdit martop10" style="width:100%;padding-bottom:20px;">
                <div class="title">
                    <p class="contenta">相册图片</p>
                    <p class="contentb"><span class="padlef20" style="color:Red;"></span><a href="#" id="butImgUrl" style="color:#1d3d83;">【点我上传图片】</a></p>
                    <input id="hidImgUrlArray" name="hidImgUrlArray" type="hidden" value='<% =imgUrl %>' />
                    <script type="text/javascript">
                        $(document).ready(function () {
                            var button = $('#butImgUrl'), interval;
                            new AjaxUpload(button, {
                                action: '',
                                onSubmit: function (file, ext) {
                                    if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) {
                                        alert('错误:图片格式不正确!');
                                        return false;
                                    }
                                    if ($("#imgArea").children("div").length >= 10) {
                                        alert('图片上传限制10张');
                                        return false;
                                    }
                                    this._settings.action = '/PageHandler/UpLoadFile.ashx?folderName=Photos/';
                                    this._settings.data = { oldFileName: $('#divImgUrl img').attr('src') };
                                    this.disable();
                                    var tips = $("#butImgUrl").prev();
                                    tips.html("文件上传中请等待");
                                    interval = window.setInterval(function () {
                                        if (tips.html().length < 20) {
                                            tips.html(tips.html() + ">");
                                        } else {
                                            tips.html('文件上传中请等待');
                                        }
                                    }, 300);
                                },
                                onComplete: function (file, response) {
                                    $("#butImgUrl").prev().html('');
                                    window.clearInterval(interval);
                                    this.enable();
                                    window.clearInterval(interval);
                                    var jsondata = JSON.parse(response);
                                    if (jsondata.Error.length == 0) {
                                        $("#imgArea").append("<div style='float:left;width:145px;height:130px;border:1px solid #eaeaea;background:#f5f5f5;margin:10px 0 0 10px;'>" +
                                        "<img alt='' src='/UserImages/Photos/" + jsondata.FileName + "' style='width:139px;height:100px;padding:3px;'/>" +
                                        "<p class='sj10 hg22 txtlef hand' onclick='$(this).parent().remove()'>删除</p></div>");
                                    } else {
                                        alert(jsondata.Error);
                                    }
                                }
                            });
                        });
                    </script>
                </div>
                <div id="imgArea" class="content">
                    <asp:Repeater ID="rptPhoto" runat="server">
                    <ItemTemplate>
                        <div style='float:left;width:145px;height:130px;border:1px solid #eaeaea;background:#f5f5f5;margin:10px 0 0 10px;'>
                            <img alt='' src='/UserImages/Photos/<%# Eval("ImgUrl")%>' style='width:139px;height:100px;padding:3px;'/>
                        <p class='sj10 hg22 txtlef hand' onclick='$(this).parent().remove()'>删除</p></div>
                    </ItemTemplate>
                    </asp:Repeater>
                </div>
            </div>
        </div>
        <div class="left" style="width:23%;margin:10px 0 0 1%;_margin:10px 0 0 0.5%;height:auto;">
            <div class="divEdit" style="width:100%;">
                <div class="title">系统信息</div>
                <div class="content">
                    <table cellpadding="0" cellspacing="0" class="tableRightEdit">
                        <tbody>
                            <tr><th>编辑人：</th></tr>
                            <tr><td><asp:Label ID="lbEditor" runat="server" Text="管理员"></asp:Label></td></tr>
                            <tr><th>创建时间：</th></tr>
                            <tr><td><asp:TextBox ID="txtCreated" runat="server" CssClass="inputText" Width="80%" onclick="return showCalendar(this.id, 'y-m-d');"></asp:TextBox></td></tr>
                         </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="clear f0" style="height:10px; width:100%"></div>
        <div class="clear divDetailOper">
            <asp:LinkButton ID="LinkButton1" runat="server" CssClass="butSave" onclick="butSave_Click" OnClientClick="return butsubmit()">保存信息</asp:LinkButton>
            <a class="butBack" href="AlbumList.aspx">返回列表</a>
        </div>
        <div class="clear f0" style="height:20px; width:100%"></div>
    </div>
</asp:Content>
